package shortlink.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import shortlink.common.convention.result.Result;
import shortlink.common.convention.result.Results;
import shortlink.dto.req.ShortLinkGroupStatsAccessRecordReqDTO;
import shortlink.dto.req.ShortLinkGroupStatsReqDTO;
import shortlink.dto.req.ShortLinkStatsAccessRecordReqDTO;
import shortlink.dto.req.ShortLinkStatsReqDTO;
import shortlink.dto.resp.ShortLinkStatsAccessRecordRespDTO;
import shortlink.dto.resp.ShortLinkStatsRespDTO;
import shortlink.service.LinkAccessStatsService;
import shortlink.service.ShortLinkStatsService;

@RestController
@RequiredArgsConstructor
public class ShortLinkStatsController {
    private final ShortLinkStatsService shortLinkStatsService;

    /*访问单个短链接指定时间内监控数据*/
    @GetMapping("/api/short-link/project/linkstats/stats")
    public Result<ShortLinkStatsRespDTO> shortLinkStats( ShortLinkStatsReqDTO requestParam) {
        return Results.success(shortLinkStatsService.oneshortLinkStats(requestParam));
    }
    /* 访问分组短链接指定时间内监控数据*/
    @GetMapping("/api/short-link/project/linkstats/groupstats")
    public Result<ShortLinkStatsRespDTO> groupShortLinkStats( ShortLinkGroupStatsReqDTO requestParam) {
        return Results.success(shortLinkStatsService.groupShortLinkStats(requestParam));
    }
    /**
     * 访问单个短链接指定时间内访问记录监控数据
     */
    @GetMapping("/api/short-link/project/linkstats/statslogs")
    public Result<IPage<ShortLinkStatsAccessRecordRespDTO>> shortLinkStatsAccessRecord( ShortLinkStatsAccessRecordReqDTO requestParam) {
        return Results.success(shortLinkStatsService.shortLinkStatsAccessRecord(requestParam));
    }
    /**
     * 访问分组短链接指定时间内访问记录监控数据
     */
    @GetMapping("/api/short-link/project/linkstats/groupstatslogs")
    public Result<IPage<ShortLinkStatsAccessRecordRespDTO>> groupShortLinkStatsAccessRecord( ShortLinkGroupStatsAccessRecordReqDTO requestParam) {
        return Results.success(shortLinkStatsService.groupShortLinkStatsAccessRecord(requestParam));
    }

}
